﻿using System;
using Grundy.Common;
using Grundy.Entity;
using Grundy.Message;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NSubstitute;

namespace Grundy.Licensing.Server.Tests
{
    [TestClass]
    public class ClientSessionTests
    {
        private Clock clock;

        [TestInitialize]
        public void Setup()
        {
            clock = Substitute.For<Clock>();
            Clock.Instance = clock;
        }


        [TestMethod]
        public void Should_have_expired()
        {
            clock.Utc.Returns(DateTime.UtcNow.AddDays(-1), DateTime.UtcNow);
            var cs = new ClientSession();
            Assert.IsTrue(cs.HasExpired());
        }

        [TestMethod]
        public void Should_not_have_expired()
        {
            clock.Utc.Returns(DateTime.UtcNow.AddDays(1), DateTime.UtcNow);
            var cs = new ClientSession();
            Assert.IsFalse(cs.HasExpired());
        }
    }
}